(function(app){
	app
		.controller("contentCtrl",["$scope","myFactory",'$http','$state','$stateParams','$window','$location',function($scope,myFactory,$http,$state,$stateParams,$window,$location){
			//接收参数
			var chdrnum01=$stateParams.chdrnum01;
			var chdrcoy=$stateParams.chdrcoy;
			var searchParam = $stateParams.searchParam;
			$scope.data = {
			}
/**********************************************初始化函数begin****************************************************/
			//初始化查询变更项内容
			$scope.load = function () {
				myFactory.loadingShow();//显示加载圈
				var token=sessionStorage.getItem("token");
				var timestamp=myFactory.getTimetamp();
				var sfis= "chdrnum-chdrcoy-token-timestamp";
				var signStr="chdrnum="+chdrnum01+"&chdrcoy="+chdrcoy+"&token="+token+"&timestamp="+timestamp;//encodeURI(tbrName)
				var sign = myFactory.hex(signStr);
				
				$http({
					method: 'GET',
					url: app.domain + 'query/doRestPolicyDetail.action',
					/*S2022081723491客户信息安全管控需求 update by Meryang 202207006 start*/
					params: {'chdrnum': chdrnum01,'chdrcoy': chdrcoy,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp,'page':'details'}
				    /*S2022081723491客户信息安全管控需求 update by Meryang 202207006 end*/
				}).then(function successCallback(response) {
					if (response.data.success) {
						//保单基本信息
						$scope.policyBasic=response.data.data.policyMap.base;
						
						//日期显示方式处理 by zzq 2018-3-6
						$scope.policyBasic.ptdate01 = DateTools($scope.policyBasic.ptdate01);//下期应邀日
						$scope.policyBasic.cltdob = DateTools($scope.policyBasic.cltdob);//投保人出生年月日
						$scope.policyBasic.rnBirthday = DateTools($scope.policyBasic.rnBirthday);//被保人出生年月日
						
						if(!isNaN($scope.policyBasic.cownIdValidity)){
							$scope.policyBasic.cownIdValidity = DateTools($scope.policyBasic.cownIdValidity);//投保人证件有效期，有可能是个日期或是“终身”，日期时候对日期进行处理
						}
						
						
						if(!isNaN($scope.policyBasic.lifcIdValidity)){
							$scope.policyBasic.lifcIdValidity = DateTools($scope.policyBasic.lifcIdValidity);//被保人证件有效期，有可能是个日期或是“终身”，日期时候对日期进行处理
						}
						
						//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
						if(!isNaN($scope.policyBasic.cownIdStartValidity)){
							$scope.policyBasic.cownIdStartValidity = DateTools($scope.policyBasic.cownIdStartValidity);//投保人证件有效期，有可能是个日期或是“终身”，日期时候对日期进行处理
						}
						
						if(!isNaN($scope.policyBasic.lifcIdStartValidity)){
							$scope.policyBasic.lifcIdStartValidity = DateTools($scope.policyBasic.lifcIdStartValidity);//被保人证件有效期，有可能是个日期或是“终身”，日期时候对日期进行处理
						}
						//S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
						
						if(response.data.data.policyMap.base.cownIdValidity=='99999999'){
							/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 start*/
							$scope.policyBasic.cownIdValidity="长期";
							/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 end*/
						}
	
						if(response.data.data.policyMap.base.cltsex=='M'){
							$scope.policyBasic.cltsex="男";
						}
						if(response.data.data.policyMap.base.cltsex=='F'){
							$scope.policyBasic.cltsex="女";
						}
	
						if(response.data.data.policyMap.base.lifcIdValidity=='99999999'){
							/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 start*/
							$scope.policyBasic.lifcIdValidity="长期";
							/*S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210719 end*/
						}
	
						if(response.data.data.policyMap.base.rnSex=='M'){
							$scope.policyBasic.rnSex="男";
						}
						if(response.data.data.policyMap.base.rnSex=='F'){
							$scope.policyBasic.rnSex="女";
						}
						
						//S2022041822029--PIC_双被保险人增额终身寿险产品系统需求 add by huanghk 20220816 start
						$scope.policyBasic.slBirthday = DateTools($scope.policyBasic.slBirthday);
						if(!isNaN($scope.policyBasic.slIdStartValidity)){
							$scope.policyBasic.slIdStartValidity = DateTools($scope.policyBasic.slIdStartValidity);
						}
						if(!isNaN($scope.policyBasic.slIdValidity)){
							$scope.policyBasic.slIdValidity = DateTools($scope.policyBasic.slIdValidity);
						}
						if(response.data.data.policyMap.base.slIdValidity=='99999999'){
							$scope.policyBasic.slIdValidity="长期";
						}
						if(response.data.data.policyMap.base.slSex=='M'){
							$scope.policyBasic.slSex="男";
						}
						if(response.data.data.policyMap.base.slSex=='F'){
							$scope.policyBasic.slSex="女";
						}
						//S2022041822029--PIC_双被保险人增额终身寿险产品系统需求 add by huanghk 20220816 end
					}
					/*护网行动 add by huanghaokun 20220705 start*/
					else{
						if (response.data.code == '-1') {
							myFactory.alert('', response.data.msg ,'info');
						}else{
							myFactory.alert('','系统没有响应，请返回重试','info');
						}
					}
					/*护网行动 add by huanghaokun 20220705 end*/
					myFactory.loadingHide();
				}, function errorCallback(response) {
					myFactory.loadingHide();
					myFactory.alert("","初始化查询失败!","info");
				});
			}
/**********************************************初始化函数end****************************************************/
			//转换日期方法  例如：20170225--->2017-02-25 by zzq 2018-3-6
			function DateTools(date){
				date = String(date) ;
				if($.trim(date)!=""){
					//S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210727 start
					if(date=="99999999"){
						return "长期";
					}
					//S2020120315839_增加记录证件有效期起始日  add by huanghaokun 20210727 end
					return date.replace(/^(\d{4})(\d{2})(\d{2})$/, "$1-$2-$3");
				}else{
					return date;
				}
			}
			
			$scope.queryPolicyDetail = function () {
				/*$.showLoading('正在查询,请稍候');
				setTimeout(function() {
					$.hideLoading();
				}, 3000);*/
			}

			$scope.goBack = function () {
				//返回查询页面,返回查询条件
				$state.go('search',{
					searchParam:searchParam
				});
			}
			
		}])
})(app)